From bcbe0c0b00b29ab301b58cf0045a99f35917bdf2 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Thu, 14 Jul 2016 19:17:08 -0400 Subject: [PATCH] Files modified in the past should not trigger a fingerprint change Previously, we would bail from the fingerprint computation if the old and new mtimes had changed in *any* way. This caused some issues of rebuilding with filesystems that do not preserve nanosecond granularity (#2874). --- src/cargo/ops/cargo_rustc/fingerprint.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index 2bef5a907..4b16a4a2e 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -172,13 +172,21 @@ impl Fingerprint { a, b) } } - (&LocalFingerprint::MtimeBased(ref a, ref ap), - &LocalFingerprint::MtimeBased(ref b, ref bp)) => { - let a = a.0.lock().unwrap(); - let b = b.0.lock().unwrap(); - if *a != *b { - bail!("mtime based components have changed: {:?} != {:?}, \ - paths are {:?} and {:?}", *a, *b, ap, bp) + (&LocalFingerprint::MtimeBased(ref on_disk_mtime, ref ap), + &LocalFingerprint::MtimeBased(ref previously_built_mtime, ref bp)) => { + let on_disk_mtime = on_disk_mtime.0.lock().unwrap(); + let previously_built_mtime = previously_built_mtime.0.lock().unwrap(); + + let should_rebuild = match (*on_disk_mtime, *previously_built_mtime) { + (None, None) => false, + (Some(_), None) | (None, Some(_)) => true, + (Some(on_disk), Some(previously_built)) => on_disk > previously_built, + }; + + if should_rebuild { + bail!("mtime based components have changed: previously {:?} now {:?}, \ + paths are {:?} and {:?}", + *previously_built_mtime, *on_disk_mtime, ap, bp) } } _ => bail!("local fingerprint type has changed"), -- 2.30.2